package com.example.livemall.mapper;

import com.example.livemall.entity.Item;
import com.example.livemall.entity.ItemForES;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SearchMapper {

    @Select("select distinct * from item " +
            "where title like '%${title}%' " +
            "or rentType like '%${rentType}%' " +
            "or houseType like '%${houseType}%'" +
            "and city = #{city}" +
            "limit #{offset}, #{size}")
    List<Item> selectItemForPage(String city, String title, String rentType, String houseType, Integer offset, Integer size);

    @Select("select distinct count(*) from item " +
            "where title like '%${title}%' " +
            "or rentType like '%${rentType}%' " +
            "or houseType like '%${houseType}%'" +
            "and city = #{city}")
    Integer selectItemForPageTotal(String city, String title, String rentType, String houseType);

    @Select("select url from imgs " +
            "where item_id = #{item_id} " +
            "and url like '%${tag}%'")
    String selectImg(String item_id, String tag);
}
